﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class BalanceCenter_BalanceCenterIndex : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {       

    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestLoginPage = this.Request.Url.AbsoluteUri;

        base.OnInit(e);
    }

    #endregion

    public string NewDataBind()
    {
        string writeString = "";

        DataTable dt = new DAL.Tables.tbl_Information().Open("top 6 *", "isShow=1 and Type = 2", "[DateTime] desc");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return "";
        }

        foreach (DataRow row in dt.Rows)
        {
            writeString += " <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>";
            writeString += " <tr><td width='20' height='30'>";
            writeString += "<img src='../images/dian_2.jpg' width='14' height='19' /></td><td width='660' align='left' class='Grey12_2'>";
            writeString += "<a href='NewsDetail.aspx?id=" + row["id"].ToString() + "'>" + row["Title"].ToString() + "</a>[" + row["DateTime"].ToString() + "]</td>";
            writeString += "</tr><tr><td height='1' colspan='2' bgcolor='#e6e6e6'></td></tr></table>";
        }

        if (dt.Rows.Count < 4)
        {
            for (int i = dt.Rows.Count; i < 4; i++)
            {
                writeString += " <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>";
                writeString += " <tr><td width='20' height='30'>";
                writeString += "<img src='../images/dian_2.jpg' width='14' height='19' /></td><td width='660' align='left' class='Grey12_2'>";
                writeString += "<a href='#'> .................</a>[2008-12-1 12:23:12]</td>";
                writeString += "</tr><tr><td height='1' colspan='2' bgcolor='#e6e6e6'></td></tr></table>";
            }
        }

        return writeString;
    }

    public string FavourableDataBind()
    {
        string writeString = "";

       DataTable dt = new DAL.Tables.tbl_Information().Open("top 6 *", "isShow=1 and Type = 1", "[DateTime] desc");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return "";
        }

        foreach (DataRow row in dt.Rows)
        {
            writeString += " <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>";
            writeString += " <tr><td width='20' height='30'>";
            writeString += "<img src='../images/dian_2.jpg' width='14' height='19' /></td><td width='660' align='left' class='Grey12_2'>";
            writeString += "<a href='NewsDetail.aspx?id=" + row["id"].ToString() + "'>" + row["Title"].ToString() + "</a>[" + row["DateTime"].ToString() + "]</td>";
            writeString += "</tr><tr><td height='1' colspan='2' bgcolor='#e6e6e6'></td></tr></table>";
        }

        if (dt.Rows.Count < 4)
        {
            for (int i = dt.Rows.Count; i < 4; i++)
            {
                writeString += " <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>";
                writeString += " <tr><td width='20' height='30'>";
                writeString += "<img src='../images/dian_2.jpg' width='14' height='19' /></td><td width='660' align='left' class='Grey12_2'>";
                writeString += "<a href='#'> .................</a>[2008-12-1 12:23:12]</td>";
                writeString += "</tr><tr><td height='1' colspan='2' bgcolor='#e6e6e6'></td></tr></table>";
            }
        }

        return writeString;
    }

    public string DistributionDataBind()
    {
        string writeString = "";

        DataTable dt = Shove.Database.MSSQL.Select("select top 15 a.id ,a.CustomerNo,sum(b.[Money]) as sumEarning from tbl_Customer a,tbl_CustomerDetails b where a.id=b.CustomerID  and b.OperatorType in (3,4)  group by a.id,a.CustomerNo order by sumEarning desc");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return "";
        }

        //int count = 1;

        //foreach (DataRow row in dt.Rows)
        //{
        //    writeString += " <tr><td bgcolor='#FFFFFF' class='Georgia14' align='center'>" + count.ToString() + "</td>";
        //    writeString += " <td bgcolor='#FFFFFF' class='Grey12_2'>";
        //    writeString += row["CustomerNo"].ToString() + "</td>";
        //    double money = Shove._Convert.StrToDouble(row["sumEarning"].ToString(), 0);
        //    string moneyStr = (money == 0) ? "0.00" : money.ToString("N");
        //    writeString += " <td bgcolor='#FFFFFF' class='orange12'>" + moneyStr + "</td></tr>";
        //    count++;
        //}

        //if (dt.Rows.Count < 4)
        //{
        //    for (int i = dt.Rows.Count; i < 4; i++)
        //    {
        //        writeString += " <table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>";
        //        writeString += " <tr><td width='20' height='30'>";
        //        writeString += "<img src='../images/dian_2.jpg' width='14' height='19' /></td><td width='660' align='left' class='Grey12_2'>";
        //        writeString += "<a href='#'> .................</a>[2008-12-1 12:23:12]</td>";
        //        writeString += "</tr><tr><td height='1' colspan='2' bgcolor='#e6e6e6'></td></tr></table>";
        //    }
        //}

        return writeString;
    }
}   

